import React from 'react';
import ReactDom from 'react-dom';
import { BrowserRouter as Router, Route, Redirect, Link, Switch } from 'react-router-dom';

// import 'font-awesome/css/font-awesome.min.css';
// import './assets/css/index.styl';

//import Home from 'page/home/Home.jsx';
import Home from 'page/home/Home.jsx';

import OrderList from 'page/order/OrderList.jsx';
import OrderDetail from 'page/order/OrderDetail.jsx';
import UserList from 'page/user/UserList.jsx';
import Login from 'page/login/Login.jsx';
import ErrorPage from 'page/error/ErrorPage.jsx';
import Layout from 'component/layout/Layout.jsx';
import ProductRouter from 'page/product/ProductRouter.jsx';

class App extends React.Component {



  render() {

    let LayoutRouter = (
      <Layout>
        <Switch>
          <Route exact path="/" component={Home} />
          <Route path="/product" component={ProductRouter} />
          <Route path="/product-category" component={ProductRouter} />
          <Route path="/order/index" component={OrderList} />
          <Route path="/order/detail/:orderNumber" component={OrderDetail} />
          <Route path="/user/index" component={UserList} />
          <Redirect exact from="/user" to="/user/index" />
          <Redirect exact from="/order" to="/order/index" />
          <Route component={ErrorPage} />
        </Switch>
      </Layout>
    );

    return (
      <Router>
        <Switch>
          <Route path="/login" component={Login} />
          <Route path="/" render={props => LayoutRouter} />
        </Switch>
      </Router>
    );
  }
}

ReactDom.render(
  <App />,
  document.getElementById('app')
);